PROXY ?=
IMAGE_REGISTRY ?= registry.xuelangyun.com/sh
IMAGE_NAME ?= sh-computing-calc-manager
IMAGE_TAG ?= latest

debug-install:
	@SKIP_CYTHON=1 pip install -e . -v

install:
	@pip install -e . -v

clean:
	@sh clean.sh
	@pip uninstall -y sh-computing-calc-manager

# 生成镜像
build-image:
	docker build \
		--build-arg http_proxy=$(PROXY) \
		--build-arg https_proxy=$(PROXY) \
		-t $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) .

push-image:
	docker push $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)

# Run tests
test:
	@python -m unittest discover -v tests

.PHONY: build-image push-image help test


# 帮助信息
help:
	@echo "Available commands:"
	@echo "  make debug-install  - Install the package without Cython compilation for debugging purposes"
	@echo "  make install        - Install the package with Cython compilation for normal use"
	@echo "  make clean          - Uninstall the package and clean up build artifacts"
	@echo "  make build-image    - Build the Docker image with the current code"
	@echo "  make push-image     - Push the built Docker image to the specified registry"
	@echo "  make help           - Display this help message"
	@echo ""
	@echo "Environment variables:"
	@echo "  PROXY               - Proxy settings for Docker build (optional)"
	@echo "  IMAGE_REGISTRY      - Docker registry URL (default: sh-platform-dev-registry.cn-shanghai.cr.aliyuncs.com/shuzhi)"
	@echo "  IMAGE_NAME          - Name of the Docker image (default: sh-computing-calc-manager)"
	@echo "  IMAGE_TAG           - Tag for the Docker image (default: latest)"
